package com.dhee.creditcardsystem.util;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DBUtilZSG {
    public static int dml(String sql, Object... args) throws SQLException {
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            conn = DBUtil.getConnection();
            pstmt = conn.prepareStatement(sql);

            for (int i = 0; i < args.length; i++) {
                pstmt.setObject(i + 1, args[i]);
            }
            return pstmt.executeUpdate();
        } catch (Exception e) {
            System.out.println("DBUtilZSG.dml()方法执行异常");

            e.printStackTrace();
        } finally {
            DBUtil.close(conn, pstmt);
        }
        return -1; // 返回-1表示失败

    }
}


